<?php
namespace App\Admin\Controllers;

use Qiniu\Auth;

class QiniuAuth {
    protected $access_key;
    protected $secret_key;

    public function __construct()
    {

    }

    public function getToken($url){
        $this->access_key = config('filesystems.disks.qiniu.access_key');
        $this->secret_key = config('filesystems.disks.qiniu.secret_key');
        
        $expire = time()+86400*1000;
        $url = $url.'?e='.$expire;

        $auth = new Auth($this->access_key, $this->secret_key);
        $token = $auth->sign($url);
        return $url.'&token='.$token;
    }
}
